package com.func.boom.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @author Yulei
 * @date 2020-08-16 14:40:50
 * @desc
 */
@RestController
public class TestController {

    @Resource
    RestTemplate restTemplate;

    private final static String URL = "http://boom-base-serve/customer/test";

    @GetMapping("/test")
    @HystrixCommand(fallbackMethod = "fallback")
    public String test(){
        return restTemplate.getForEntity(URL, String.class).getBody();
    }

    public String fallback(){
        return "error";
    }

}
